//
//  XKHomeNewsCell.m
//  xk100
//
//  Created by xiaokang on 2017/5/17.
//  Copyright © 2017年 xiaokang. All rights reserved.
//

#import "XKHomeNewsCell.h"

@interface XKHomeNewsCell ()
@property (nonatomic, strong) UIImageView   *imgView;
@property (nonatomic, strong) UILabel       *label;
@end
@implementation XKHomeNewsCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = WhiteColor;
        self.imgView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imgView];
        [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentView).offset(10);
            make.left.mas_equalTo(self.contentView).offset(10);
            make.right.mas_equalTo(self.contentView).offset(-10);
            make.height.mas_equalTo(100*Scale_H);
        }];
        
        self.label = [UILabel getLabWithText:@""
                                    textFont:Font_12
                                   textColor:BlackColor
                               textAlignment:NSTextAlignmentLeft];
        [self.contentView addSubview:self.label];
        [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.imgView.mas_bottom).offset(5);
            make.left.right.mas_equalTo(self.imgView);
            make.bottom.mas_equalTo(self.contentView).offset(-10);
        }];
    }
    return self;
}

- (void)setImageName:(NSString *)imageName {
    _imageName = imageName;
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:imageName]
                    placeholderImage:[UIImage imageNamed:@"index_con_infor_banner"]
                             options:SDWebImageProgressiveDownload];
}
- (void)setTitleName:(NSString *)titleName {
    _titleName = titleName;
    self.label.text = titleName;
}

- (void)setFlag:(NSInteger)flag {
    _flag = flag;
    if (flag % 2 == 0) {
        [self.imgView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).offset(10);
            make.right.mas_equalTo(self.contentView).offset(-5);
        }];
    } else {
        [self.imgView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).offset(5);
            make.right.mas_equalTo(self.contentView).offset(-10);
        }];
    }
}
@end
